//
//  MainLecturiVC.m
//  test
//
//  Created by 李彦宏 on 2018/3/7.
//  Copyright © 2018年 朱圳. All rights reserved.
//

#import "MainLecturiVC.h"
#import "LecturingtableCtry.h"//未付款
#import "PrepaidFeeVC.h"//已付款
#import "JWGRUsermodel.h"
#import "JWUserManager.h"

@interface MainLecturiVC ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *contArry;
@property (nonatomic, strong) JWGRUsermodel *model;

@end

@implementation MainLecturiVC
//UItableView初始化
- (void)setupTable
{
    UITableView *tableView=[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    //隐藏组距导航栏的间距
    tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];
    tableView.backgroundColor=[UIColor whiteColor];
    tableView.showsHorizontalScrollIndicator=NO;
    tableView.showsVerticalScrollIndicator=NO;
    tableView.dataSource=self;
    tableView.delegate=self;
tableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
    [self.view addSubview:tableView];
    self.tableView=tableView;

}
- (void)viewDidLoad {
    [super viewDidLoad];
    _contArry=[NSMutableArray arrayWithObjects:@"未打款",@"已打款", nil];
    self.model=[JWUserManager Gme];
    
    [self setupTable];
    
}
#pragma -mark -----------------------------tableview datasource and delegate---------------------------------
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 45;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    // 1.创建cell
    static NSString *ID = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    }
    
    // 2.设置cell的数据
    cell.textLabel.text = _contArry[indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.row) {
        case 0:{
            LecturingtableCtry *vc=[[LecturingtableCtry alloc]init];
            vc.title=[NSString stringWithFormat:@"%@的未打款",self.model.name];
            [self.navigationController pushViewController:vc animated:YES];
            break;
        }
        case 1:{
            PrepaidFeeVC *vc=[[PrepaidFeeVC alloc]init];
            vc.title=[NSString stringWithFormat:@"%@的已打款",self.model.name];
            [self.navigationController pushViewController:vc animated:YES];
            break;
        }
        default:
            break;
    }
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 1;
}


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 1;
}


-(NSMutableArray *)contArry{
    if(_contArry==nil){
        _contArry=[[NSMutableArray alloc]init];
    }
    return _contArry;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
